<%@page import="com.rivercloud.entity.UserVo"%>
<%@page import="java.util.List"%>
<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!-- alan_18.2.7 -->
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
<head>
<base href="<%=basePath%>">
<title>未完成表格</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" href="${base}/css/bootstrap.css">
<link href="${base}/css/font-awesome.css?v=4.4.0" rel="stylesheet">
<!-- Sweet Alert -->
<link href="${base}/css/plugins/sweetalert/sweetalert.css"
	rel="stylesheet">
<link href="${base}/css/animate.css" rel="stylesheet">

<script type="text/javascript" src="${base}/js/jquery-3.1.0.js"></script>
<script type="text/javascript" src="${base}/js/bootstrap.js"></script>
<script src="${base}/js/content.js?v=1.0.0"></script>
<!-- Sweet alert -->
<script src="${base}/js/plugins/sweetalert/sweetalert.min.js"></script>
</head>

<body>
	<div class="container">
		<jsp:include page="${path}/menu.jsp"></jsp:include>
		<div style="margin-left: 20px;margin-bottom: 10px; color: grey">当前位置：表格管理 > 未完成表格</div>
		
		<div class="container-fluid">
			<div class="row-fluid">
				<div class="span12">

					<div>
						<%-- <input type="button" class="btn btn-success" value="${project.projectName}"> --%>
						<a href="${base}/table/joinTableList?userId=${user.id}&projectId=${project.id}"><input  id="idb" type="button" class="btn btn-success" value="我参与的" style="background-color: gray"><a>
						<a href="${base}/table/creatorTableList?userId=${user.id}&projectId=${project.id}"><input id="ida" type="button" class="btn btn-success" value="我管理的" ><a>
						<a href="${base}/table/tableList?userId=${user.id}&projectId=${project.id}"><input  id="idb" type="button" class="btn btn-success" value="全部" style="background-color: gray" ><a>
					</div>
					<c:if test="${empty tableList}">
						<h4>
							<span style="color: red;">当前项目暂无已完成表格，请前往新建表格</span>
							 <a href="${pageContext.request.contextPath}/tpl/addTable">新建表格</a> 
							
						</h4>

					</c:if>

					<c:if test="${!empty tableList}">
						<!-- alan_18.2.7_start_update_style -->
						<table class="table table-striped table-bordered table-hover dataTables-example">
							<thead>
								<tr bgcolor="#9BCD9B">
									<th>表格名称</th>
									<th>创建人</th>
									<th>创建时间</th>

									<th>删除表格</th>
								</tr>
							</thead>
							<%-- <c:if test="${empty tableList}">
								<h4>
									<span style="color: red;">列表为空,暂无文件</span>
									<a href="${base}/createTable.jsp">新建表格</a>
								</h4>
							</c:if> --%>
							<tbody>



								<c:forEach items="${tableList}" var="table">
									<tr class="gradeX">
										<%-- <td><a href="${pageContext.request.contextPath}/template.jsp">${template.templateName }</a></td> --%>
										<%-- <td><a href="${pageContext.request.contextPath}/table/tableInfo?tableId=${table.id}">${table.tableName }</a></td>
										 --%>
										<td><a href="${base}/excel/editTable?tableName=${table.tableName}&tableId=${table.id}&userId=${user.id}&projectId=${project.id}">${table.tableName }</a></td>
										<td>${table.creator }</td>
										<td><fmt:formatDate type="both" dateStyle="short" timeStyle="short" value="${table.createTime}" /></td>
										<!-- alan_18.2.7_end_update_style -->

										<%-- <td>
											<button class="btn btn-danger btn-sm" onclick="deleteExcel(${table.id})">delete</button>
												
										</td> --%>
										<td><%-- <c:set scope="page" value="delete_table" var="pageDelete"></c:set>
										<!-- 为每个要判断的按钮或者功能定义一个变量，对应数据库后台的权限表中的keyword字段 -->
										 <% 
											  String pageDelete=(String)pageContext.getAttribute("pageDelete");
											  //然后改变这里取出来
											  UserVo userVo=(UserVo)session.getAttribute("userVo");
											  String keyword=userVo.getpKeyword();
											  System.out.println(keyword);
											 String [] keywords=keyword.split(",");
												  Boolean flag=false;
												  if(keywords.length>1){
													  flag=keyword.contains(pageDelete);//这里改变
												  }else{
													  flag=keyword.equals(pageDelete);//这里改变，最后就能实现了
												  }
												  System.out.println(userVo.getuName()+"权限为："+flag);
												   if(flag){
											%> --%>
													<c:set scope="page" value="manager" var="pagein"></c:set>
										<!-- 为每个要判断的按钮或者功能定义一个变量，对应数据库后台的权限表中的keyword字段 -->
							 <% 
								  String pageDelete=(String)pageContext.getAttribute("pagein");
								  //然后改变这里取出来
								  System.out.print(pageDelete);
								  UserVo userVo=(UserVo)session.getAttribute("userVo");
								  System.out.print(userVo);
								  if(userVo != null){
								  String keyword=userVo.getrKeyword();
								  System.out.println(keyword);
								 String [] keywords=keyword.split(",");
									  Boolean flag=false;
									 	
										  flag=keyword.equals(pageDelete);//这里改变，最后就能实现了
									  
									  System.out.println(userVo.getuName()+"权限为："+flag);
									   if(flag){
								%>

											<button class="btn btn-danger btn-sm" onclick="deleteExcel(${table.id})">delete</button>
										<% 	
							 				}
								  }
							
						 				%>
										</td>
									</tr>
								</c:forEach>


							</tbody>
						</table>
					</c:if>
					<div>
						<a href="${pageContext.request.contextPath}/tpl/addTable" ><input type="button"
							class="btn btn-success" value="新建表格" ></a>
						
					</div>

				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
		/* function bbb(){
			alert(11);
		} */

		function deleteExcel(obj) {
		    
		    var param = "tableId=" + obj;
		    if (confirm("确认删除"+param+"吗？")){
				$.ajax({
					url: "${base}/table/delete",
					data: param,
					dataType: "json",
					type: "POST",
					success: function (data) {
						//Location.href = "${base}/excel/list";
						alert("删除成功");
		                location.reload();
					},
					async: true,
					cache: false
					});
		    }
		}
	/* $('.delete').click(function() {
		swal({
			title : "您确定要删除该表格吗",
			text : "删除后将无法恢复，请谨慎操作！", 
			type : "warning",
			showCancelButton : true,
			confirmButtonColor : "#DD6B55",
			confirmButtonText : "删除",
			closeOnConfirm : false
		}, function() {
			

			swal("删除成功！", "您已经删除了该表格。", "success");

		});
	}); */
		function bbb(){
    		document.getElementById("ida").style.backgroundColor="green";
    			document.getElementById("idb").style.backgroundColor="gray";
    			
    		
    	}
    	function ccc(){
    		document.getElementById("idb").style.backgroundColor="green";
    			document.getElementById("ida").style.backgroundColor="gray";
    			
    	}

	$(".tr").bind("mouseover", function() {
		$(this).css("background-color", "#eeeeee");
	})
	$(".tr").bind("mouseout", function() {
		$(this).css("background-color", "#ffffff");
	})
</script>
</html>


